<template>
    <div class="reportFormPage">
        <div class="report-dom">
            <el-row>
                <el-col :span="5" :offset="19">
                    <div class="pageNumBox">
                        <span>第</span>
                        <span class="placeholder-min text-center">&nbsp;{{ form.page }}&nbsp;</span>
                        <span>页，共</span>
                        <span class="placeholder-min text-center">&nbsp;{{ form.totalPage }}&nbsp;</span>
                        <span>页</span>
                    </div>
                </el-col>
            </el-row>
            <div class="topTwoBox">
                <div class="centerName">水泥密度、细度试验检测记录表</div>
                <div class="codeText">
                    <tr>JGLQ04001</tr>
                    <tr>JGLQ04002</tr>
                </div>
            </div>
            <div class="threeTopBox">
                <div class="left-border">
                    <div class="box-title">检测单位名称：</div>
                    <div class>{{ form.jiancdwmc }}</div>
                </div>
                <div class="right-border">
                    <span>记录编号：</span>
                    <span v-if="isPdf" class="placeholder">{{ form.jilbh }}</span>
                    <el-input class="code-input" v-else type="text" v-model="form.jilbh" @focus="handleFocus('jilbh')"/>
                </div>
            </div>
            <div class="table-border">
                <!------------------------------表头-------------------------->
                <table height="220px" class="top-table">
                    <tbody>
                    <tr>
                        <td height="30" align="center" width="15%">
                            <span style="width: 90px; display: inline-block">工程名称</span>
                        </td>
                        <td width="35%" class="text-center">
                            <span>{{ form.gongcmc }}</span>
                        </td>
                        <td align="center" width="15%">
                            <span style="width: 90px; display: inline-block">工程部位/用途</span>
                        </td>
                        <td width="35%" class="text-center">
                            <span>{{ form.gongcbwyt }}</span>
                        </td>
                    </tr>
                    <tr>
                        <td height="50" align="center">样品信息</td>
                        <td class="specimen-border" colspan="3">
                            <span>样品名称：</span>
                            <span :class="{ placeholder: !form.yangpmc }">{{ form.yangpmc }}</span>
                            <span>；样品编号：</span>
                            <span :class="{ 'placeholder-long': !form.yangpbh }">{{ form.yangpbh }}</span>
                            <span>；样品数量：</span>
                            <span :class="{ placeholder: !form.yangpsl }">{{ form.yangpsl }}</span>
                            <span>；样品状态：</span>
                            <span :class="{ placeholder: !form.yangpzt }">{{ form.yangpzt }}</span>
                            <span>；来样时间：</span>
                            <span :class="{ placeholder: !form.yangpsj }">{{ form.yangpsj }}</span>
                        </td>
                    </tr>

                    <tr>
                        <td height="25" align="center" width="15%">
                            <span style="width: 90px; display: inline-block">试验检测日期</span>
                        </td>
                         <!-- <td width="35%" class="text-center">{{ form.shiyjcrq }}</td> -->                                            
 <td width="35%" class="text-center">
      <el-input v-model="form.shiyjcrq" />
</td>
                        <td align="center" width="15%">
                            <span style="width: 90px; display: inline-block">试验条件</span>
                        </td>
                        <td v-if="isPdf" width="35%">
                            温度：
                            <span style="display: inline-block; width: 10%">{{ form.shiytjwd }}</span>
                            ℃；湿度：
                            <span style="display: inline-block; width: 10%">{{ form.shiytjsd }}</span>%RH
                        </td>
                        <td v-else width="35%">
                            温度：
                            <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjwd" style="width: 15%"/>
                            ℃；湿度：
                            <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjsd" style="width: 15%"/>
                            %RH
                        </td>
                    </tr>

                    <tr>
                        <td height="50" align="center" width="15%">
                            <span style="width: 90px; display: inline-block">检测依据</span>
                        </td>
                        <td width="35%">
                            <span v-if="isPdf">{{ form.jiancyj }}</span>
                            <el-input v-else type="textarea" v-model="form.jiancyj" :rows="2" class="mark"
                                      @dblclick.native="showBsJiancyjView" readonly/>
                        </td>
                        <td align="center" width="15%">
                            <span style="width: 90px; display: inline-block">判定依据</span>
                        </td>
                        <td width="35%">
                            <span v-if="isPdf">{{ form.pandyj }}</span>
                            <el-input v-else type="textarea" v-model="form.pandyj" :rows="2"
                                      @dblclick.native="showBsJudgeBaseView"
                                      @focus="handleFocus('pandyj')" class="mark"/>
                        </td>
                    </tr>
                    <tr class="bottom-border">
                        <td height="50" align="center">
                            <div>主要仪器设备</div>
                            <div>名称及编号</div>
                        </td>
                        <td colspan="3">
                            <span v-if="isPdf">{{ form.zhuyyqsbmcjbh }}</span>
                            <el-input v-else type="textarea" :rows="2" v-model="form.zhuyyqsbmcjbh"
                                      class="height100 width100 mark"
                                      @dblclick.native="showBsInstrumentView" readonly></el-input>
                        </td>
                    </tr>
                    </tbody>
                </table>
                <!------------------------------表中-------------------------->
                <table height="616px" class="middle-table">
                    <tbody>
                    <tr height="25">
                        <td colspan="10">密度</td>
                    </tr>
                    <tr height="40">
                        <td>试验次数</td>
                        <td colspan="2">试样质量(g)</td>
                        <td colspan="2">
                            李氏瓶第一次读数V₁
                            <br/>(mL)
                        </td>
                        <td colspan="2">
                            李氏瓶第二次读数V₂
                            <br/>(mL)
                        </td>
                        <td colspan="2">
                            水泥的密度ρ
                            <br/>(g/cm³)ρ= m/V₂-V₁
                        </td>
                        <td>平均值(g/cm³)</td>
                    </tr>
                    <tr height="25">
                        <td>
                            <span>1</span>
                        </td>
                        <td colspan="2">
                            <el-input type="number"
                                      v-model="form.midsyzl1"
                                      @change="calculateNum1('A', form.midsyzl1)"
                                      @keydown.native="handleKeyDown($event, 0, 0)"
                                      @paste.native="handlePaste($event, 0, 0)"
                                      :ref="'0_0'"/>
                        </td>
                        <td colspan="2">
                            <el-input type="number"
                                      v-model="form.middyc1"
                                      @change="calculateNum1('B', form.middyc1)"
                                      @keydown.native="handleKeyDown($event, 0, 1)"
                                      @paste.native="handlePaste($event, 0, 1)"
                                      :ref="'0_1'"/>
                        </td>
                        <td colspan="2">
                            <el-input type="number"
                                      v-model="form.middec1"
                                      @change="calculateNum1('C', form.middec1)"
                                      @keydown.native="handleKeyDown($event, 0, 2)"
                                      @paste.native="handlePaste($event, 0, 2)"
                                      :ref="'0_2'"/>
                        </td>
                        <td colspan="2">
                            <span>{{ form.midmd1 }}</span>
                        </td>
                        <td rowspan="2">
                            <span>{{ form.midpjz }}</span>
                        </td>
                    </tr>
                    <tr height="25">
                        <td>
                            <span>2</span>
                        </td>
                        <td colspan="2">
                            <el-input type="number"
                                      v-model="form.midsyzl2"
                                      @change="calculateNum2('A', form.midsyzl2)"
                                      @keydown.native="handleKeyDown($event, 1, 0)"
                                      @paste.native="handlePaste($event, 1, 0)"
                                      :ref="'1_0'"/>
                        </td>
                        <td colspan="2">
                            <el-input type="number"
                                      v-model="form.middyc2"
                                      @change="calculateNum2('B', form.middyc2)"
                                      @keydown.native="handleKeyDown($event, 1, 1)"
                                      @paste.native="handlePaste($event, 1, 1)"
                                      :ref="'1_1'"/>
                        </td>
                        <td colspan="2">
                            <el-input type="number"
                                      v-model="form.middec2"
                                      @change="calculateNum2('C', form.middec2)"
                                      @keydown.native="handleKeyDown($event, 1, 2)"
                                      @paste.native="handlePaste($event, 1, 2)"
                                      :ref="'1_2'"/>
                        </td>
                        <td colspan="2">
                            <span>{{ form.midmd2 }}</span>
                        </td>
                    </tr>

                    <tr height="25">
                        <td colspan="10">水泥细度( /μm 筛析法)</td>
                    </tr>
                    <tr height="40">
                        <td>试验次数</td>
                        <td colspan="2">
                            试样质量W
                            <br/>(g)
                        </td>
                        <td>
                            筛余物
                            <br/>质量R₁(g)
                        </td>
                        <td colspan="2">
                            筛余百分数
                            <br/>F(%）F=R₁/W*100
                        </td>
                        <td>修正系数C</td>
                        <td colspan="2">
                            修正后筛余百分数
                            <br/>(%）F*C
                        </td>
                        <td>平均值(%)</td>
                    </tr>
                    <tr height="25">
                        <td>
                            <span>1</span>
                        </td>
                        <td colspan="2">
                            <el-input type="number"
                                      v-model="form.xidsyzl1"
                                      @change="calculateNum3('A', form.xidsyzl1)"
                                      @keydown.native="handleKeyDown($event, 2, 0)"
                                      @paste.native="handlePasteTwo($event, 0, 0)"
                                      :ref="'2_0'"/>
                        </td>
                        <td>
                            <el-input type="number"
                                      v-model="form.xidzl1"
                                      @change="calculateNum3('B', form.xidzl1)"
                                      @keydown.native="handleKeyDown($event, 2, 1)"
                                      @paste.native="handlePasteTwo($event, 0, 1)"
                                      :ref="'2_1'"/>
                        </td>
                        <td colspan="2">
                            <span>{{ form.xidbfs1 }}</span>
                        </td>
                        <td rowspan="2">
                            <el-input type="number"
                                      v-model="form.xidxs1"
                                      @change="calculateNum3('D', form.xidxs1)"
                                      @keydown.native="handleKeyDown($event, 2, 2)"
                                      :ref="'2_2'"/>
                        </td>
                        <td colspan="2">
                            <span>{{ form.xidxzbfs1 }}</span>
                        </td>
                        <td rowspan="2">
                            <span>{{ form.xidpjz }}</span>
                        </td>
                    </tr>
                    <tr height="25">
                        <td>
                            <span>2</span>
                        </td>
                        <td colspan="2">
                            <el-input type="number"
                                      v-model="form.xidsyzl2"
                                      @change="calculateNum4('A', form.xidsyzl2)"
                                      @keydown.native="handleKeyDown($event, 3, 0)"
                                      @paste.native="handlePasteTwo($event, 1, 0)"
                                      :ref="'3_0'"/>
                        </td>
                        <td>
                            <el-input type="number"
                                      v-model="form.xidzl2"
                                      @change="calculateNum4('B', form.xidzl2)"
                                      @keydown.native="handleKeyDown($event, 3, 1)"
                                      @paste.native="handlePasteTwo($event, 1, 1)"
                                      :ref="'3_1'"/>
                        </td>
                        <td colspan="2">
                            <span>{{ form.xidbfs2 }}</span>
                        </td>
                        <td colspan="2">
                            <span>{{ form.xidxzbfs2 }}</span>
                        </td>
                    </tr>

                    <tr height="25">
                        <td colspan="10">比表面积</td>
                    </tr>
                    <tr height="40">
                        <td width="5%">参数</td>
                        <td style="width: calc(95% / 9)">试样密度(g/cm³)</td>
                        <td style="width: calc(95% / 9)">试料层体积(cm³)</td>
                        <td style="width: calc(95% / 9)">空隙率</td>
                        <td style="width: calc(95% / 9)">试样质量(g)</td>
                        <td style="width: calc(95% / 9)">温度(℃)</td>
                        <td style="width: calc(95% / 9)">液面降落时间(s)</td>
                        <td style="width: calc(95% / 9)">空气粘度(µPa·s)</td>
                        <td style="width: calc(95% / 9)">比表面积(m²/kg)</td>
                        <td style="width: calc(95% / 9)">平均值(m²/kg)</td>
                    </tr>
                    <tr height="25">
                        <td>
                            <span>标样</span>
                        </td>
                        <td>
                            <el-input type="number"
                                      v-model="form.bibmjsymdby"
                                      @change="calculateNum5('A', form.bibmjsymdby)"
                                      @keydown.native="handleKeyDown($event, 4, 0)"
                                      @paste.native="handlePasteThree($event, 0, 0)"
                                      :ref="'4_0'"/>
                        </td>
                        <td>
                            <el-input type="number"
                                      v-model="form.bibmjsyctjby"
                                      @change="calculateNum5('A', form.bibmjsymdby)"
                                      @keydown.native="handleKeyDown($event, 4, 1)"
                                      @paste.native="handlePasteThree($event, 0, 1)"
                                      :ref="'4_1'"/>
                        </td>
                        <td>
                            <el-input type="number"
                                      v-model="form.bibmjkxlby"
                                      @change="calculateNum5('A', form.bibmjkxlby)"
                                      @keydown.native="handleKeyDown($event, 4, 2)"
                                      @paste.native="handlePasteThree($event, 0, 2)"
                                      :ref="'4_2'"/>
                        </td>
                        <td>
                            <span>{{ form.bibmjsyzlby }}</span>
                        </td>
                        <td>
                            <el-select v-model="form.bibmjwdby" class="hide-icon height100" placeholder
                                       @change="shuiwenChange('bibmjwdby', 'bibmjkqndby')">
                                <el-option v-for="(item, index) in shuiwenList" :key="index" :label="item.temp"
                                           :value="item.temp"></el-option>
                            </el-select>
                        </td>
                        <td>
                            <el-input type="number"
                                      v-model="form.bibmjymjlsjby"
                                      @change="updateSnComputeApi"
                                      @keydown.native="handleKeyDown($event, 4, 3)"
                                      @paste.native="handlePasteThree($event, 0, 3)"
                                      :ref="'4_3'"/>
                        </td>
                        <td>
                            <span>{{ form.bibmjkqndby }}</span>
                        </td>
                        <td>
                            <el-input type="number" v-model="form.bibmjbbmjby" @change="updateSnComputeApi"
                                      @keydown.native="handleKeyDown($event, 4, 4)" :ref="'4_4'"/>
                        </td>
                        <td>
                            <span>/</span>
                        </td>
                    </tr>
                    <tr height="25">
                        <td>
                            <span>1</span>
                        </td>
                        <td>
                            <el-input type="number"
                                      v-model="form.bibmjsymd1"
                                      @change="calculateNum5('B', form.bibmjsymd1)"
                                      @keydown.native="handleKeyDown($event, 5, 0)"
                                      @paste.native="handlePasteThree($event, 1, 0)"
                                      :ref="'5_0'"/>
                        </td>
                        <td>
                            <el-input type="number"
                                      v-model="form.bibmjsyctj1"
                                      @change="calculateNum5('B', form.bibmjsyctj1)"
                                      @keydown.native="handleKeyDown($event, 5, 1)"
                                      @paste.native="handlePasteThree($event, 1, 1)"
                                      :ref="'5_1'"/>
                        </td>
                        <td>
                            <el-input type="number"
                                      v-model="form.bibmjkxl1"
                                      @change="calculateNum5('B', form.bibmjkxl1)"
                                      @keydown.native="handleKeyDown($event, 5, 2)"
                                      @paste.native="handlePasteThree($event, 1, 2)"
                                      :ref="'5_2'"/>
                        </td>
                        <td>
                            <span>{{ form.bibmjsyzl1 }}</span>
                        </td>
                        <td>
                            <el-select v-model="form.bibmjwd1" class="hide-icon height100" placeholder
                                       @change="shuiwenChange('bibmjwd1', 'bibmjkqnd1')"
                            >
                                <el-option v-for="(item, index) in shuiwenList" :key="index" :label="item.temp"
                                           :value="item.temp"></el-option>
                            </el-select>
                        </td>
                        <td>
                            <el-input type="number"
                                      v-model="form.bibmjymjlsj1"
                                      @change="updateSnComputeApi"
                                      @keydown.native="handleKeyDown($event, 5, 3)"
                                      @paste.native="handlePasteThree($event, 1, 3)"
                                      :ref="'5_3'"/>
                        </td>
                        <td>
                            <span>{{ form.bibmjkqnd1 }}</span>
                        </td>
                        <td>
                            <span>{{ form.bibmjbbmj1 }}</span>
                        </td>
                        <td rowspan="2">
                            <span>{{ form.bibmjpjz }}</span>
                        </td>
                    </tr>
                    <tr height="25">
                        <td>
                            <span>2</span>
                        </td>
                        <td>
                            <el-input type="number"
                                      v-model="form.bibmjsymd2"
                                      @change="calculateNum5('C', form.bibmjsymd2)"
                                      @keydown.native="handleKeyDown($event, 6, 0)"
                                      @paste.native="handlePasteThree($event, 2, 0)"
                                      :ref="'6_0'"/>
                        </td>
                        <td>
                            <el-input type="number"
                                      v-model="form.bibmjsyctj2"
                                      @change="calculateNum5('C', form.bibmjsyctj2)"
                                      @keydown.native="handleKeyDown($event, 6, 1)"
                                      @paste.native="handlePasteThree($event, 2, 1)"
                                      :ref="'6_1'"/>
                        </td>
                        <td>
                            <el-input type="number"
                                      v-model="form.bibmjkxl2"
                                      @change="calculateNum5('C', form.bibmjkxl2)"
                                      @keydown.native="handleKeyDown($event, 6, 2)"
                                      @paste.native="handlePasteThree($event, 2, 2)"
                                      :ref="'6_2'"/>
                        </td>
                        <td>
                            <span>{{ form.bibmjsyzl2 }}</span>
                        </td>
                        <td>
                            <el-select v-model="form.bibmjwd2" class="hide-icon height100" placeholder
                                       @change="shuiwenChange('bibmjwd2', 'bibmjkqnd2')"
                            >
                                <el-option v-for="(item, index) in shuiwenList" :key="index" :label="item.temp"
                                           :value="item.temp"></el-option>
                            </el-select>
                        </td>
                        <td>
                            <el-input type="number"
                                      v-model="form.bibmjymjlsj2"
                                      @change="updateSnComputeApi"
                                      @keydown.native="handleKeyDown($event, 6, 3)"
                                      @paste.native="handlePasteThree($event, 2, 3)"
                                      :ref="'6_3'"/>
                        </td>
                        <td>
                            <span>{{ form.bibmjkqnd2 }}</span>
                        </td>
                        <td>
                            <span>{{ form.bibmjbbmj2 }}</span>
                        </td>
                    </tr>
                    <tr height="25">
                        <td colspan="2">检测项目</td>
                        <td colspan="2">允许差值</td>
                        <td colspan="3">实际差值</td>
                        <td colspan="3">结果判定</td>
                    </tr>
                    <tr height="25">
                        <td colspan="2">比表面积(%)</td>
                        <td colspan="2">
                            <!-- <el-input type="text" v-model="form.baDetailVos[73].jiszb" class="mark" @dblclick.native="showBsJudgeBaseEditView('73')" readonly /> -->
                            <el-input type="text" v-model="form.yunxcz" class="mark"
                                      @dblclick.native="showBsJudgeBaseEditView('73')" readonly/>

                            <!-- <el-input type="number" v-model="form.yunxcz" /> -->
                        </td>
                        <td colspan="3">
                            <span>{{ form.shijcz }}</span>
                            <!-- <el-input type="number" v-model="form.shijcz" /> -->
                        </td>
                        <td colspan="3">
                            <span>{{ form.jiegpd }}</span>
                        </td>
                    </tr>
                    </tbody>
                </table>
                <!------------------------------附加声明-------------------------->
                <table height="30px" class="bottom-table">
                    <tr>
                        <td>
                            <span v-if="isPdf" class="textarea-span">{{ form.fujsm }}</span>
                            <el-input v-else type="textarea" :rows="2" v-model="form.fujsm"
                                      @focus="handleFocus('fujsm')"/>
                        </td>
                    </tr>
                </table>
            </div>
            <!------------------------------表底-------------------------->
            <table height="22px" class="transparent">
                <tbody>
                <tr>
                    <td width="10%" align="right">检测：</td>
                    <td width="15%" align="left"></td>
                    <td width="10%" align="right">记录：</td>
                    <td width="15%" align="left"></td>
                    <td width="10%" align="right">复核：</td>
                    <td align="left" width="15%"></td>
                    <td width="10%">日期：</td>
                    <td align="left" width="15%">
                        <div style="display: inline-block; margin-left: 20px">年</div>
                        <div style="display: inline-block; margin-left: 20px">月</div>
                        <div style="display: inline-block ;margin-left: 20px">日</div>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <bs-instrument-view ref="bsInstrumentViewRef" @select="selectInstrument"></bs-instrument-view>
        <bs-jiancyj-view ref="bsJiancyjViewRef" @select="selectJiancyj" :syType="syType"></bs-jiancyj-view>
        <bs-judge-base-view ref="bsJudgeBaseViewRef" @select="selectJudge" :syType="syType"></bs-judge-base-view>
        <bs-judge-base-edit-view ref="bsJudgeBaseEditViewRef" @submit="selectJudgeBaseEdit"
                                 :syType="syType"></bs-judge-base-edit-view>
    </div>
</template>

<script>
import {getSnmdxdjcjlbBsInfo, updateSnCompute} from "@/api/report_sn/snmdxdjcjlbBsInfo";
import BsInstrumentView from "@/views/dept/bsInstrument/BsInstrumentView.vue";
import BsJiancyjView from "@/views/sycs/bsJiancyj/BsJiancyjView.vue";
import {emptyConvert, handleFocus, handleKeyDown, handlePaste} from "@/views/reportForms/utils";
import BsJudgeBaseView from "@/views/sycs/bsJudgeBase/BsJudgeBaseView.vue";
import Bus from "@/utils/bus";
import decimal from "@/utils/big-decimal";
import BsJudgeBaseEditView from "@/views/sycs/bsJudgeBase/BsJudgeBaseEditView.vue";

import {listBySyTypeId} from "@/api/sycs/dataBase";

export default {
    name: "snjsjcjlb",
    components: {
        BsInstrumentView,
        BsJiancyjView,
        BsJudgeBaseView,
        BsJudgeBaseEditView
    },
    props: {
        excelId: {
            type: [String, Number],
            default: () => ""
        },
        syType: {
            type: [String, Number],
            default: () => ""
        },
        page: {
            type: Number,
            default: () => 0
        },
        isPdf: {
            type: Boolean,
            default: () => false
        },
        printEmpty: {
            type: Boolean,
            default: () => false
        }
    },
    data() {
        return {
            shuiwenList: [],
            params: {},
            query: {},
            // 表单参数
            form: {},
            // 表单校验
            rules: {
                excelId: [{required: true, message: "主键不能为空", trigger: "blur"}]
            }
        };
    },

    created() {
        this.getInfo();
        this.getShuiwenList();
    },
    methods: {
        getShuiwenList() {
            listBySyTypeId({syYjId: "2143842384353"}).then((response) => {
                const data = response.data;
                this.shuiwenList = data.page.records;
            });
        },
        // 获取详情
        getInfo() {
            getSnmdxdjcjlbBsInfo(this.excelId || this.$defaultExcelId).then((response) => {
                this.form = response.data;
                if (!this.form.fujsm) {
                    this.form.fujsm = "附加声明：";
                }
            });
        },

        // 显示检测依据列表
        showBsJiancyjView() {
            this.$refs.bsJiancyjViewRef.init(this.form.jiancyjIds);
        },
        // 检测依据选择
        selectJiancyj(info) {
            this.form.jiancyj = info.label;
            this.form.jiancyjIds = info.ids;
            Bus.$emit("setSnBgJiancyj", {jiancyj: this.form.jiancyj, jiancyjIds: this.form.jiancyjIds});
        },

        // 显示判定依据列表
        showBsJudgeBaseView() {
            this.$refs.bsJudgeBaseViewRef.init(this.form.pandyjIds);
        },
        // 判断依据选择
        selectJudge(info) {
            if (!this.form.pandyj) {
                this.form.pandyj = info.label;
                return;
            }
            if (info && info.label) {
                this.form.pandyj += "、" + info.label;
            }
        },

        // 显示仪器列表
        showBsInstrumentView() {
            this.$refs.bsInstrumentViewRef.init(this.form.shebIds);
        },
        // 仪器选择
        selectInstrument(info) {
            this.form.zhuyyqsbmcjbh = info.label;
            this.form.shebIds = info.ids;
            Bus.$emit("setSnBgZhuyyqsbmcjbh", {zhuyyqsbmcjbh: this.form.zhuyyqsbmcjbh, shebIds: this.form.shebIds});
        },

        handleFocus(event) {
            handleFocus(event, this.page, this.form[event]);
        },
        calculateNum1(type, val) {
            let A = this.form.midsyzl1 ? this.form.midsyzl1 : 0;
            let B = this.form.middyc1 ? this.form.middyc1 : 0;
            let C = this.form.middec1 ? this.form.middec1 : 0;
            let D = this.form.midmd2 ? this.form.midmd2 : 0;
            let midmd1 = decimal.round(A / (C - B));
            let pjz = (Number(midmd1) + Number(D)) / 2;
            this.form.midmd1 = midmd1;
            this.form.midpjz = decimal.round(pjz);
            // 密度
            Bus.$emit("setSNBgJiancjg", [{key: 72, value: this.form.midpjz}]);
            // 比表面积
            Bus.$emit("setSNBgJiancjg", [{key: 73, value: ""}]);
        },
        calculateNum2(type, val) {
            let A = this.form.midsyzl2 ? this.form.midsyzl2 : 0;
            let B = this.form.middyc2 ? this.form.middyc2 : 0;
            let C = this.form.middec2 ? this.form.middec2 : 0;
            let D = this.form.midmd1 ? this.form.midmd1 : 0;
            let midmd2 = decimal.round(A / (C - B));
            let pjz = (Number(midmd2) + Number(D)) / 2;

            this.form.midmd2 = midmd2;
            this.form.midpjz = decimal.round(pjz);
            // 密度
            Bus.$emit("setSNBgJiancjg", [{key: 72, value: this.form.midpjz}]);
            // 比表面积
            Bus.$emit("setSNBgJiancjg", [{key: 73, value: ""}]);
        },
        calculateNum3(type, val) {
            if (type == "A" || type == "B") {
                let A = this.form.xidsyzl1 || 0;
                let B = this.form.xidzl1 || 0;
                this.form.xidbfs1 = decimal.round((100 * B) / A || 0, 1);
            } else if (type == "D") {
                let C1 = this.form.xidbfs1 || 0;
                let C2 = this.form.xidbfs2 || 0;
                this.form.xidxzbfs1 = decimal.round(C1 * val, 1);
                this.form.xidxzbfs2 = decimal.round(C2 * val, 1);
                this.form.xidpjz = decimal.round((C1 * val + C2 * val) / 2, 1);
                // 水泥细度(
                Bus.$emit("setSNBgJiancjg", [
                    {
                        key: 84,
                        value: this.form.xidpjz
                    }
                ]);
            }
        },
        calculateNum4(type, val) {
            let A = this.form.xidsyzl2 || 0;
            let B = this.form.xidzl2 || 0;
            this.form.xidbfs2 = decimal.round((100 * B) / A, 1);
        },
        calculateNum5(type, val) {
            if (type == "A") {
                let A = this.form.bibmjsymdby || 0;
                let B = this.form.bibmjsymdby || 0;
                let C = this.form.bibmjkxlby || 0;
                this.form.bibmjsyzlby = decimal.round(A * B * (1 - C), 3);
            } else if (type == "B") {
                let A = this.form.bibmjsymd1 || 0;
                let B = this.form.bibmjsyctj1 || 0;
                let C = this.form.bibmjkxl1 || 0;
                this.form.bibmjsyzl1 = decimal.round(A * B * (1 - C), 3);
            } else {
                let A = this.form.bibmjsymd2 || 0;
                let B = this.form.bibmjsyctj2 || 0;
                let C = this.form.bibmjkxl2 || 0;
                this.form.bibmjsyzl2 = decimal.round(A * B * (1 - C), 3);
            }
            this.updateSnComputeApi();
        },
        shuiwenChange(name, setName) {
            const info = this.shuiwenList.find((item) => item.temp == this.form[name]);
            if (!info) {
                return;
            }
            this.form[setName] = info.viscosity;
        },
        setComputeData() {
            return {
                bibmjsymdby: this.form.bibmjsymdby, //A
                bibmjkxlby: this.form.bibmjkxlby, //C
                bibmjymjlsjby: this.form.bibmjymjlsjby, //D
                bibmjbbmjby: this.form.bibmjbbmjby, //F
                bibmjsymd1: this.form.bibmjsymd1, //G
                bibmjkxl1: this.form.bibmjkxl1, //H
                bibmjymjlsj1: this.form.bibmjymjlsj1, //I
                bibmjsymd2: this.form.bibmjsymd2, //2G
                bibmjkxl2: this.form.bibmjkxl2, //2H
                bibmjymjlsj2: this.form.bibmjymjlsj2 //2I
                // 求bibmjbbmj1,bibmjbbmj2
            };
        },
        updateSnComputeApi() {
            let data = this.setComputeData();
            updateSnCompute(data).then((res) => {
                this.form.bibmjbbmj1 = decimal.round(Number(res.data.bibmjbbmj1), 0) || "";
                this.form.bibmjbbmj2 = decimal.round(Number(res.data.bibmjbbmj2), 0) || "";
                let a = Number(this.form.bibmjbbmj1) + Number(this.form.bibmjbbmj2);
                this.form.bibmjpjz = decimal.round(a / 2, 0);
                this.form.shijcz = decimal.round(Number(res.data.shijcz), 1) || "";
            });
        },
        // 显示单个技术编辑
        showBsJudgeBaseEditView(key) {
            let info = {
                excelId: "1813465723728125952",
                id: 675,
                jiancjg: "0.0",
                jiegpd: "实测值",
                jiszb: "-",
                num1: null,
                num2: null,
                qualId: 73,
                qualName: "比表面积",
                qualUnit: "(m2/kg)",
                refQualId: 73,
                symbolValue: null
            };
            // const info = this.form.baDetailVos[key];
            info.refQualId = info.qualId;
            this.$refs.bsJudgeBaseEditViewRef.init(info);
        },
        // 编辑单个技术指标后赋值
        selectJudgeBaseEdit(info) {
            this.form.num1 = info.num1;
            this.form.num2 = info.num2;
            this.form.symbolValue = info.symbolValue;
            updateSnCompute({...this.form}).then((res) => {
                this.form.shijcz = decimal.round(Number(res.data.shijcz), 1) || "";
                this.form.yunxcz = res.data.yunxcz;
                this.form.jiegpd = res.data.jiegpd;
            });
        },
        submitForm() {
            return this.form;
        },
        handleKeyDown(event, rowIndex, colIndex) {
            const maxArr = [2, 2, 2, 1, 4, 3, 3]; // 每一行最多有多少可聚焦输入框（从0开始）
            const ref = handleKeyDown(event, rowIndex, colIndex, maxArr);
            if (this.$refs[ref]) {
                this.$refs[ref].focus();
            }
        },
        // 粘贴赋值方法-密度
        handlePaste(event, rowIndex, colIndex) {
            const nameAllArr = [
                ["midsyzl1", "middyc1", "middec1"],
                ["midsyzl2", "middyc2", "middec2"],
            ];
            const subscriptArr = [
                [0, 1, 2],
                [0, 1, 2],
            ];

            const methodsAllArr = [
                ["calculateNum1", "calculateNum1", "calculateNum1"],
                ["calculateNum2", "calculateNum2", "calculateNum2"],
            ];
            const parameterArr = [
                ['A-'+this.form.midsyzl1, 'B-'+this.form.middyc1, 'C-'+this.form.middec1],
                ['A-'+this.form.midsyzl2, 'B-'+this.form.middyc2, 'C-'+this.form.middec2],
            ];
            const data = handlePaste(event, rowIndex, colIndex, nameAllArr, methodsAllArr, parameterArr, subscriptArr);
            const {cols, nameSetArr, methodsSetArr, parameterSetArr, subscriptSetArr} = data;
            for (let a = 0; a < nameSetArr.length; a++) {
                for (let b = 0; b < nameSetArr[a].length; b++) {
                    this.form[nameSetArr[a][b]] = cols[a][b];
                }
            }
            for (let a = 0; a < methodsSetArr.length; a++) {
                for (let b = 0; b < methodsSetArr[a].length; b++) {
                    if (methodsSetArr[a][b]){
                        let parameter = parameterSetArr[a][b];
                        let parameterArr = parameter ? parameter.split("-") : []
                        if (parameterArr.length >= 2) {
                            this.setCalculate(methodsSetArr[a][b], parameterArr[0], parameterArr[1]);
                        }
                    }
                }
            }
        },

        // 粘贴赋值方法-水泥细度
        handlePasteTwo(event, rowIndex, colIndex) {
            const nameAllArr = [
                ["xidsyzl1", "xidzl1"],
                ["xidsyzl2", "xidzl2"],
            ];
            const subscriptArr = [
                [0, 1],
                [0, 1],
            ];

            const methodsAllArr = [
                ["calculateNum3", "calculateNum3"],
                ["calculateNum4", "calculateNum4"],
            ];
            const parameterArr = [
                ['A-'+this.form.xidsyzl1, 'B-'+this.form.xidzl1],
                ['A-'+this.form.xidsyzl2, 'B-'+this.form.xidzl2],
            ];
            const data = handlePaste(event, rowIndex, colIndex, nameAllArr, methodsAllArr, parameterArr, subscriptArr);
            const {cols, nameSetArr, methodsSetArr, parameterSetArr, subscriptSetArr} = data;
            for (let a = 0; a < nameSetArr.length; a++) {
                for (let b = 0; b < nameSetArr[a].length; b++) {
                    this.form[nameSetArr[a][b]] = cols[a][b];
                }
            }
            for (let a = 0; a < methodsSetArr.length; a++) {
                for (let b = 0; b < methodsSetArr[a].length; b++) {
                    if (methodsSetArr[a][b]){
                        let parameter = parameterSetArr[a][b];
                        let parameterArr = parameter ? parameter.split("-") : []
                        if (parameterArr.length >= 2) {
                            this.setCalculate(methodsSetArr[a][b], parameterArr[0], parameterArr[1]);
                        }
                    }
                }
            }
        },

        // 粘贴赋值方法-比表面积
        handlePasteThree(event, rowIndex, colIndex) {
            const nameAllArr = [
                ["bibmjsymdby", "bibmjsyctjby", "bibmjkxlby", "bibmjymjlsjby"],
                ["bibmjsymd1", "bibmjsyctj1", "bibmjkxl1", "bibmjymjlsj1"],
                ["bibmjsymd2", "bibmjsyctj2", "bibmjkxl2", "bibmjymjlsj2"],
            ];
            const subscriptArr = [
                [0, 1, 2, 3],
                [0, 1, 2, 3],
                [0, 1, 2, 3],
            ];

            const methodsAllArr = [
                ["calculateNum5", "calculateNum5", "calculateNum5", "updateSnComputeApi"],
                ["calculateNum5", "calculateNum5", "calculateNum5", "updateSnComputeApi"],
                ["calculateNum5", "calculateNum5", "calculateNum5", "updateSnComputeApi"],
            ];
            const parameterArr = [
                ['A-'+this.form.bibmjsymdby, 'A-'+this.form.bibmjsymdby, 'A-'+this.form.bibmjkxlby, null],
                ['B-'+this.form.bibmjsymd1, 'B-'+this.form.bibmjsyctj1, 'B-'+this.form.bibmjkxl1, null],
                ['C-'+this.form.bibmjsymd2, 'C-'+this.form.bibmjsyctj2, 'C-'+this.form.bibmjkxl2, null],
            ];
            const data = handlePaste(event, rowIndex, colIndex, nameAllArr, methodsAllArr, parameterArr, subscriptArr);
            const {cols, nameSetArr, methodsSetArr, parameterSetArr, subscriptSetArr} = data;
            for (let a = 0; a < nameSetArr.length; a++) {
                for (let b = 0; b < nameSetArr[a].length; b++) {
                    this.form[nameSetArr[a][b]] = cols[a][b];
                }
            }
            for (let a = 0; a < methodsSetArr.length; a++) {
                for (let b = 0; b < methodsSetArr[a].length; b++) {
                    if (methodsSetArr[a][b]){
                        let parameter = parameterSetArr[a][b];
                        let parameterArr = parameter ? parameter.split("-") : []
                        if (parameterArr.length >= 2) {
                            this.setCalculate(methodsSetArr[a][b], parameterArr[0], parameterArr[1]);
                        }
                    }
                }
            }
        },

        // 计算方法调用
        setCalculate(name, a, b, c, d, e) {
            this[name](a, b, c, d, e);
        }
    }
};
</script>

<style scoped></style>
